home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1988-08-16 | 2.4 KB | 84 lines |
- IMPLEMENTATION MODULE KermDel;
- (************************************************************************)
- (* Deletes one or more files from disk *)
- (* written: 11.12.85 Matthias Aebi *)
- (* last modification: 18.03.86 Matthias Aebi *)
- (************************************************************************)
-
- FROM FileSystem IMPORT Lookup, Close, Rename, File;
- FROM Terminal IMPORT WriteString, Write, WriteLn, Read;
- FROM OutTerminal IMPORT WriteC;
- FROM String IMPORT Insert;
- FROM NameSearch IMPORT FindNames, NextName;
- FROM M2Kermit IMPORT Param1;
-
- CONST
- UpLowEqual = TRUE;
-
- (************************************************************************)
- PROCEDURE Delete;
- (************************************************************************)
- VAR
- fileName : ARRAY [0..20] OF CHAR;
- answer : CHAR;
- theFile : File;
- foundOne : BOOLEAN;
- noFile : BOOLEAN;
- fileNo : CARDINAL;
- versionNo : CARDINAL;
- counter : CARDINAL;
-
-
- BEGIN
- IF Param1[0] = "?"
- THEN
- WriteString("Specify file to delete (including wildcards)");
- ELSE
- counter := 0;
- noFile := TRUE;
- FindNames("DK", Param1, UpLowEqual);
-
- REPEAT
- NextName(foundOne, fileName, fileNo, versionNo);
- IF foundOne
- THEN
- WriteLn;
- noFile := FALSE;
- Insert(fileName, 0, "DK."); (* add device name *)
-
- WriteString("Do you want to delete the file ");
- WriteString(fileName);
- WriteString(" (y/n) ? ");
- answer := "X";
- Read(answer);
-
- IF CAP(answer) = "Y"
- THEN
- WriteString("yes");
- Lookup(theFile, fileName, FALSE);
- Rename(theFile,"DK.");
- Close(theFile);
- INC(counter);
- ELSE
- WriteString("no");
- END;
- END;
- UNTIL NOT foundOne;
-
- WriteLn;
-
- IF noFile
- THEN
- WriteString("File not found");
- ELSE
- WriteC(counter,3);
- WriteString(" file(s) deleted");
- END;
- WriteLn;
-
- END;
-
- END Delete;
-
- END KermDel.
-